home *** CD-ROM | disk | FTP | other *** search
- Path: earth.superlink.net!usenet
- From: Michael Rizzo <rizzom@mars.superlink.net>
- Newsgroups: comp.lang.c++
- Subject: Help: error while linking: unresolved external symbol
- Date: Mon, 04 Mar 1996 07:02:58 -0500
- Organization: SuperNet Inc. (908) 828-8988
- Message-ID: <313ADBF2.5FAB@mars.superlink.net>
- NNTP-Posting-Host: ez8.superlink.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- Hi,
-
- I am using MS Visual C++ 4.0 trying to create a console app.
- The problem is:
- I have template class:
-
- template <class T> class MemManager
- {
- T *mem[100];
- public:
- MemManager();
- T Fetch(int);
- Store(T, int);
- ~MemManager() {delete [] *mem;};
- };
-
- template <class T> MemManager<T>::MemManager()
- {
- for (int i=0;i<100;i++)
- mem[i] = new T;
- }
-
- template <class T> T MemManager<T>::Fetch(int ind)
- {
- return *mem[ind];
- }
-
- template <class T> MemManager<T>::Store(T element, int ind)
- {
- *mem[ind] = element;
- }
-
- I then instantiate the template class in the following way:
- class VMProc
- {
- stateType state; //previously defined enum type
- int PC, AC;
- char IR[11];
- MemManager<mstring> instMemMan; //previously declared class
- MemManager<int> dataMemMan;
-
- public:
- VMProc();
- void DisplayMem();
- boolean Initialize();
- stateType GetState();
- void DoInstruction();
- };
-
- These class definitions are in the same .h file with the template class
- being defined first. The code for the member functions is also in the
- same .cpp file.
-
- Ant time I call the Store member function, I get LNK2001: unresolved
- external symbol public: int __thiscall MemManager<class
- mstring>::Store(class
- mstring,int)"(?Store@?$MemManager@Vmstring@@@@QAEHVmstring@@H@Z)
-
- and the same thing for the class instantiated as <int>.
-
- As I am relativly new to C++, this is driving me nuts! I have been
- reading the help file that come with the compiler, but I just can't
- figure this out. (Mostly because I am not entirely sure what an
- unresolved external symbol error means)
- Any help would be greatly appreciated.
- Thanks in advance
-
- Mike Rizzo
- rizzom@mars.superlink.net
-